package com.wpml.cloud.classroom.msg;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
public class Message<T> {
    private String type;       //MessageType
    private T body;
    private String message;

    /**
     * 失败消息
     * @param type
     * @param message
     * @return
     */
    public static Message error(String type, String message) {
        return build(type, null, message);
    }

    /**
     * 登录消息
     * @param type
     * @param message
     * @return
     */
    public static Message success(String type, String message) {
        return build(type, null, message);
    }

    /**
     * 登录消息
     * @param type
     * @param body
     * @param message
     * @return
     */
    public static <T> Message<T> build(String type, T body, String message) {
        return new Message<>(type, body, message);
    }

}
